
<template name="sendcar">
  <!-- 盘点统计 查询货位下的盘点物资情况 -->
  <view class="mypage">
    <!-- <view class="cu-bar search bg-white">
      <view class="search-form round">
        <text class="cuIcon-search"></text>
        <input type="text" placeholder="请输入物资名称" v-model="keyword" />
        <input type="text" placeholder="请输入物资规格" v-model="keyword2" />
      </view>
      <view class="action">
        <button class="cu-btn bg-blue shadow-blur round" @tap="handelSearch">搜索</button>
      </view>
    </view> -->

    <view class="card-list-wrapper">
      <view
        class="card-list-row radius shadow-warp bg-white margin-top"
        v-for="(item,index) in planList"
        :key="index"
      >
        <view class="flex-just-between bottom-border top-wrap">
          <text class="text-blue text-bold">物资单号：{{ item.PK_MATERIAL || item.BILLNO }}</text>
          <view class="cu-capsule radius">
            <view class="cu-tag bg-blue sm">
              <text class="cuIcon-medal"></text>
            </view>
            <view class="cu-tag line-brown sm">{{ index+1}}</view>
          </view>
        </view>

        <view class="card-list-row-1 margin-top">
          <text>名称：{{ item.MATERIALNAME || item.VNAME || '' }}</text>
        </view>

        <view class="card-list-row-1">
          <text>规格：{{ item.MATSPEC || '' }}</text>
        </view>
				
				<view class="card-list-row-1">
				  <text>条码：{{ item.BARCODE || '' }}</text>
				</view>
				<view class="card-list-row-1">
				  <text>盘点次数：{{ item.TIMES || '' }}</text>
				</view>
				<view class="card-list-row-1">
				  <text>货位：{{ item.STATIONNAME || '' }}</text>
				</view>
        <!-- <view class v-if="category=='ST_STOCKINFO' ">
          <view class="card-list-row-1">
            <text class="cuIcon-title text-orange"></text>
            <text>库存总量：{{ item.TOTALNUM  }}({{ item.UNIT || '' }})</text>
          </view>
          <view class="card-list-row-1" v-for="(itemS,indexS) in mapSattionName(item.VBDEF18)">
            <text class="cuIcon-title text-red"></text>
            <text>{{ indexS+1 }}号货位：{{ itemS.STATIONNAME || '' }}/{{ itemS.KCNUM }} {{ item.UNIT }}</text>
          </view>
        </view> -->

        
      </view>
    </view>

    <!-- <view class="next-btn-wrap position-f" @click="nextTap">
      <button class="big-btn bg-green shadow-blur">
        <text class="refresharrow text-bold"></text>
      </button>
    </view> -->

    <modal
      title="高级查询"
      placeholder
      :isShow="isShowModal"
      @cancelModal="cancelModal"
      @okModal="okModal"
    ></modal>
  </view>
</template>

<script>
import { mapState, mapMutations } from "vuex";
import api from "@/common/api.js";
import utils from "@/common/util.js";
import modal from "@/components/modal/modal_mater.vue";
let query = {
 "page": 1,
 "rows": "10",
 "sidx": "",
 "sord": "",
 "queryJson": "",
 "TYPE": "3",
 "BILLNO": "",
 "DATE": "2020-08",
 "userId": "",
 "account": ""
};

let _self,
  menuType,
  page = 1,
  billID,
  total = 1,
  goPath = "",
  pageTitle = "基础物资列表(",
  queryJson = {};

export default {
  computed: mapState(["userInfo", "baseUrl", "checkData"]),
  data() {
    return {
      planList: [],
      keyword: "",
      keyword2: "",
      category: "",
      isShowModal: false,
      config: {
        materId: "",
        materName: ""
      }
    };
  },

  onLoad(p) {
    console.log(p)
    _self = this;
		query.BILLNO = p.id
		this.setCheckData([]);
    this.initData();
  },
  components: {
    modal
  },
  onNavigationBarButtonTap(e) {
		e.index == 0? (this.isShowModal = true): this.openScanMater();
  },
 
  //下拉刷新
  onPullDownRefresh: function() {
    // 重置分页及数据
    page = 1;
    total = 1;
    _self.planList = [];
    this.getList();
    setTimeout(function() {
      uni.stopPullDownRefresh();
    }, 1000);
    uni.showToast({
      title: "数据已刷新",
      icon: "none"
    });
  },
  // 加载更多
  onReachBottom: function() {
    this.getList();
  },
  methods: {
    ...mapMutations(["setCheckData"]),
    initData() {
      query.userId = _self.userInfo.UserId;
      query.account = _self.userInfo.Account;
      queryJson.PK_ORG = _self.userInfo.ORGANIZEID;
      page = 1;
      total = 1;
      this.getList();
    },
		// STATIONNAME 遍历仓库
		mapSattionName(data){
			if(!data) return [];
			let arr = JSON.parse(data);
			return arr ;
		},
		
		// 扫描物资
		openScanMater(){
			
		},
		
    
    getList() {
      if (page > total) {
        return utils.tips("没有数据了");
      }
      query.page = page;
      query.queryJson = JSON.stringify(queryJson);
      console.log(query);
      this.$utils.mShowLoading();
      let URL = '/api/APPCommon//GetListPage_Count';
      console.log(URL);
			this.axios({
				url: URL ,
				data: query ,
				isLoading: 1
			}).then(res=>{
				let { Result } = res ;
				_self.planList = [..._self.planList,...Result.rows] ;
				total = Result.total;
				page++;
			})
    },
    setPageTitle(d) {
      uni.setNavigationBarTitle({
        title: d
      });
    },

    // 控制高级查询条件
    cancelModal() {
      this.isShowModal = false;
    },
    okModal(val) {
      this.cancelModal();
      queryJson = { ...val };
      page = 1;
      total = 1;
      _self.planList = [];
      this.getList();
    }
  }
};
</script>

<style>
page{
	padding-bottom: 100rpx;
	box-sizing: border-box;
}
.card-list-wrapper {
  width: 710upx;
  margin: 0 auto;
}

.card-list-row {
  padding: 20upx;
}

.card-list-row-1 {
  padding: 10upx 0;
}



.top-border {
  border-top: 1upx solid rgba(0, 0, 0, 0.1);
}

.top-wrap {
  padding-bottom: 20upx;
}

.bottom-border {
  border-bottom: 1upx solid rgba(0, 0, 0, 0.1);
}

.btn-wrap {
  padding-top: 20upx;
}

.checkFlag {
  top: 50%;
  right: 20upx;
  font-size: 40upx;
}

.next-btn-wrap {
  position: fixed;
  right: 50upx;
  bottom: 100upx;
}

.big-btn {
  width: 100upx;
  height: 100upx;
  border-radius: 50upx;
  font-size: 40upx;
}
</style>
